package com.example.security.service.serviceImpl;


import com.example.security.utils.MD5Util;
import org.springframework.security.crypto.password.PasswordEncoder;

public class MD5PasswordEncoder implements PasswordEncoder {
    /**
     * 加密方法
     * @param charSequence
     * @return
     */
    @Override
    public String encode(CharSequence charSequence) {
        return MD5Util.generate(charSequence.toString());
    }

    /**
     * 密码比较
     * @param charSequence
     * @param encodedPassword
     * @return
     */
    @Override
    public boolean matches(CharSequence charSequence, String encodedPassword) {
        return encodedPassword.equals(MD5Util.generate(charSequence.toString()));
    }
}